import com.hubu.map.SimpleHashMap;


/**
 *
 *
 * 使用HashMap实现HashSet数据结构
 * @param <K>
 */
public class SimpleHashSet<K>{
    private static final Object object=new Object();
    private SimpleHashMap<K,Object> map=new SimpleHashMap<>();
    public boolean add(K key){
        Object value = map.put(key, object);
        return value==null?true:false;
    }
    public boolean contains(K key){
        return map.put(key,object)!=null;
    }
    public boolean   remove(K key){
         Object result=map.remove(key);
         return result!=null?true:false;
    }

    public int size(){
        return map.size();
    }

    public int capacity(){
        return map.capacity();
    }

}
